﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;

namespace Barbar.MapReport.Configuration {
  public class MapConfigurationManager {
    private static object SyncRoot = new object();
    private static MapSettingsSection Settings;
    public const string GeocoderUrl = "http://maps.google.com/maps/geo?output=xml&q={0}&key={1}";

    public static string HandlerUrl {
      get {
        if (HttpContext.Current == null)
          return MapSettings.HandlerUrl;

        return HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + MapSettings.HandlerUrl;
      }
    }
    
    public static MapSettingsSection MapSettings {
      get {
        lock (SyncRoot) {
          if (Settings == null)
            Settings = (MapSettingsSection)ConfigurationManager.GetSection("mapSettings");
          return Settings;
        }
      }
    }
  }
}
